package org.bao.bestmatch.utils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;


/**
 * write String to a file.
 * @author baoxiwu<bb@feijiao.info>,Cell&Module,BOE DT
 * @version 0.9.0
 * @since 2010-11-22
 * @license LGPL
 * 
 */
public class Writer {
	public static final String FILE_PATH_DEFAULT = "result.txt";
	
	
	public static void out(String content){
		Writer.out("./" + Cal.getDateTime() + "_" + Writer.FILE_PATH_DEFAULT,content);
	}
	
	public static void out(String path, String content){
		Writer.out(path,content,false);
	}
	
	public static void out(String path, String content, boolean append){
		try {
			File file = new File(path);
			FileWriter fw = new FileWriter(file,append);
			BufferedWriter bw = new BufferedWriter(fw);
			
			bw.write(content);
			bw.flush();
			
			bw.close();
			fw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
